// This file is part of streaminfo.
//
// Foobar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//  
// Foobar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//  
// You should have received a copy of the GNU General Public License
// along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _STREAM_SUMMARY_H_
#define _STREAM_SUMMARY_H_

#include <unordered_map>

template<class T>
class counter;
template<class T>
class bucket;

template<class T>
class heavy_hitters {
  typedef T tokentype;
public:
  void heavy_hitters_replace_min(tokentype *token);
  void heavy_hitters_add (tokentype &token);
  void print_counters();
  void print_buckets();
  void clear_counters();
  heavy_hitters(int max_counters = 300);
protected:
  bucket<T>* stream_summary;
  int summary_size;
  int MAX_COUNTERS;

  std::unordered_map<tokentype,counter<T>*> counters;
};

#endif //_STREAM_SUMMARY_H_
